<template>
  <div id="app">
    <h2>测试题</h2>
    <SubjectItem v-for="(item,index) in num" :key="index" @change="changeMsg" :index="index" :num="num"></SubjectItem>
    <div>
      <FlagItemVue :num="num" :msg="msg" @change="newIndex"></FlagItemVue>
    </div>
  </div>
</template>

<script>
import FlagItemVue from './components/FlagItem.vue';
import SubjectItem from './components/SubjectItem.vue';
export default {
  components:{
    FlagItemVue,
    SubjectItem
  },
  data(){
    return {
      num:[{id:1},{id:2},{id:3},{id:4},],
      msg:'',
      index:1
    }
  },
  methods:{
    changeMsg(newVal){
      this.msg=newVal
      // console.log(newVal);
    },
    newIndex(newVal){
      console.log(newVal);
    }
  }
};
</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>